var windowName = "taskVote";
var Page;
apiready = function(){
    onWindowShow(function () {
        console.log(windowName + " show")
    })
    onWindowHide(function () {
        console.log(windowName + " hide")
    })
    console.log("index page is OK");
    Page = createVM("#Page",{
        price:""
        ,tips:""
        ,disable:false
        ,targetPrice:0
    },{
        //页面方法
        "init":function () {
            var data = getData4Page()
            var id = data.id
            var price = data.price
            if (isTrue(price)) {
                //一口价模式
                Page.targetPrice = price
                Page.price = price
            }
            this.id = id;
        }
        ,submit:function () {
            if (!isTrue(this.price)){showToast("请输入报价");return}
            if (!isTrue(this.tips)){this.tips = "无";}

            apiPost("/api/taskVotes",{task:this.id,price:this.price,tips:this.tips},function (res , code) {
                if (code == 200) {
                    gobackDelay()
                }
                logJson(res);
                showToast(res.message)
            })

        }
    })
    Page.init()
}